﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace _20240316WinFormsApp
{
    public partial class EnvironmentMonitorForm : Form
    {
        public EnvironmentMonitorForm()
        {
            InitializeComponent();
        }

        private void EnvironmentMonitorForm_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            Random random = new Random();
            double temperature2 = random.Next(0, 35);
            double humidity2 = random.Next(25, 75);
            double pm25 = random.Next(0, 200);

            pm.Text = $"{pm25}";
            temperature.Text = $"{temperature2}°C";
            humidity.Text = $"{humidity2}";
            StringBuilder sb = new StringBuilder();
            if (temperature2 > 27)
            {
                sb.Append("温度过高\n");
            }
            else if(temperature2 < 15)
            {
                sb.Append("温度过低\n");
            }

            if (humidity2 > 50)
            {
                sb.Append("湿度过高\n");

            }
            else if(humidity2 <40)
            {
                sb.Append("湿度过低\n");
            }

            if (pm25 < 25)
            {
                sb.Append("空气质量好\n");
            }
            else if(pm25 >100)
            {
                sb.Append("空气质量差\n");
            }
            if(sb.ToString().Equals("") || sb.ToString() == null)
            {
                sb.Append("一切正常\n");
            }
            MessageBox.Show(sb.ToString());

        }
    }
}
